package com.zhangh.summer.admin.controller.role;

import com.zhangh.summer.admin.biz.role.RoleBiz;
import com.zhangh.summer.admin.model.bo.DataBO;
import com.zhangh.summer.admin.model.bo.NoValidatorBO;
import com.zhangh.summer.admin.model.po.AdRolePO;
import com.zhangh.summer.admin.support.base.JsonResponse;
import com.zhangh.summer.admin.support.ds.common.pager.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: TODO
 * @author: zhanghui  zhanghlucky@163.com
 * @create: 2021-10-08 21:44
 **/
@RestController
@RequestMapping(value = "/role",method = RequestMethod.POST)
public class RoleController {
    @Autowired
    private RoleBiz roleBiz;

    @RequestMapping("/dataPager")
    public String dataPager(@RequestBody DataBO query) {
        DataPager<AdRolePO> dataPager=this.roleBiz.getRoleDataPager(query,query.getPager());
        return new JsonResponse().toJson(dataPager);
    }

    @RequestMapping("/getRole/{id}")
    public String getRole(@PathVariable Long id) {
        AdRolePO adRolePO=this.roleBiz.getRolePO(id);
        return new JsonResponse().toJson(adRolePO);
    }

    @RequestMapping("/save")
    public String save(@RequestBody AdRolePO adRolePO) {
        long c1=this.roleBiz.saveRole(adRolePO);
        return new JsonResponse().toJson(c1);
    }

    @RequestMapping("/update")
    public String update(@RequestBody AdRolePO adRolePO) {
        int c1=this.roleBiz.updateRole(adRolePO);
        return new JsonResponse().toJson(c1);
    }

    @RequestMapping("/delete")
    public String delete(@RequestBody DataBO dataBO) {
        int c1=this.roleBiz.deleteRole(dataBO.getId());
        return new JsonResponse().toJson(c1);
    }

    @RequestMapping("/validateRoleNo")
    public String validateRoleNo(@RequestBody NoValidatorBO noValidatorBO) {
        boolean bl=this.roleBiz.validateRoleNo(noValidatorBO);
        return new JsonResponse().toJson(bl);
    }



}
